{extend name="foxcms" /}

{block name="css"}

{/block}

{block name="body"}
<div class="foxcms-content-inner">
    <!-- page content -->
    <div class="contact-way-content">
        <div class="section section-panel">
            <div class="section-title">添加链接</div>
            <div class="section-main">
                <div class="section-main-item">
                    <div class="foxui-input-group">
                        <div class="input-label">
                            <label class="foxui-required">排序：</label>
                        </div>
                        <div class="input-box">
                            <input class="foxui-size-small" placeholder="请输入" name="sort" type="number"/>
                        </div>
                    </div>
                    <p class="input-box-info">
                        <span>数字越大，排名越靠前</span>
                    </p>
                </div>
                <div class="section-main-item">
                    <div class="foxui-input-group">
                        <div class="input-label">
                            <label>标题：</label>
                        </div>
                        <div class="input-box">
                            <div class="foxui-input-suffix">
                                <input class="foxui-size-small" maxlength="15" placeholder="请输入标题" name="title" />
                                <i class="foxui-suffix-icon foxui-suffix-count">0/30</i>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="section-main-item">
                    <div class="foxui-input-group foxui-align-items-start">
                        <div class="input-label">
                            <label>图片：</label>
                        </div>
                        <div class="input-box">
                            <div class="foxui-images">
                                <div class="foxui-images-card img_url">
                                    <ul class="foxui-images-list">
                                        <div class="foxui-images-handle">
                                            <div class="foxui-images-handle-inner">
                                                <i class="foxui-icon-jiahao-o"></i>
                                                <span class="text">添加图片</span>
                                            </div>
                                        </div>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <p class="input-box-info">
                        图片尺寸建议根据前端网站模板的尺寸制作，请将所有幻灯片图片尺寸保持一致
                        <span class="example" id="erwm-example1">示例</span>
                    </p>
                </div>
                <div class="section-main-item">
                    <div class="foxui-input-group">
                        <div class="input-label">
                            <label>链接：</label>
                        </div>
                        <div class="input-box">
                            <input class="foxui-size-small" placeholder="请输入链接地址" required name="link" />
                        </div>
                    </div>
                </div>

                <div class="section-main-item">
                    <div class="foxui-input-group">
                        <div class="input-label">
                            <label class="foxui-required">状态：</label>
                        </div>
                        <div class="input-box">
                            <div class="foxui-radio-group">
                                <div class="foxui-radio is-checked">
                                    <span class="foxui-radio-input">
                                        <i class="foxui-radio-icon"></i>
                                        <input type="radio" value="1" name="status"/>
                                    </span>
                                    <span class="foxui-radio-label">启用</span>
                                </div>
                                <div class="foxui-radio">
                                    <span class="foxui-radio-input">
                                        <i class="foxui-radio-icon"></i>
                                        <input type="radio" value="0" name="status"/>
                                    </span>
                                    <span class="foxui-radio-label">禁用</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

{include file="footed-copy"/}
<div class="foxcms-content-footer">
    <button class="is-long foxui-size-small foxui-solid-primary" id="save">保存</button>
</div>
{/block}

{block name="js"}

<script>


    //保存
    $('#save').click(function (){

        //排序
        let sort = $('input[name="sort"]').val()

        //标题
        let title = $('input[name="title"]').val();
        if(title == "" || !title){
            foxui.message({
                type:'info',
                text:'请输入幻灯片标题'
            })
            return;
        }
        //图片
        let img_url = $('.img_url img').attr('src');

        //链接
        let link = $('input[name="link"]').val()
        //状态
        let status = $('.foxui-radio.is-checked input').val();
        let datas ={"sort": sort, "title":title, "img_url":img_url, "link":link, "status":status};

        foxui.dialog({
            title: '保存',
            content: '您确定要保存吗',
            cancelText: '取消',
            confirmText: '保存',
            confirm: function (callback) {
                ajaxR('add','post',datas,{},function (res) {
                    if (res.code == 1) {
                        foxui.message({
                            type:'success',
                            text:res.msg
                        })
                        window.location.href=document.referrer;//返回并且刷新
                    } else {
                        foxui.message({
                            type:'danger',
                            text:res.msg
                        })
                    }
                }, function (res) {
                    foxui.message({
                        type:'danger',
                        text:res.msg
                    })
                })
                callback();
            },
            cancel: function () {
                foxui.message({
                    type:'warning',
                    text:'取消操作'
                })
            },
        });

    })


</script>
{/block}
